package net.eyra.struts;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ExceptionHandler;
import org.apache.struts.config.ExceptionConfig;

public class EyraExceptionHandler extends ExceptionHandler {

    public ActionForward execute(Exception ex, ExceptionConfig arg1, ActionMapping arg2, ActionForm arg3, HttpServletRequest request, HttpServletResponse response) {
        if (!request.getRemoteAddr().equals("127.0.0.1")) {
            try {
                request.getSession().setAttribute("exception", ex);
                response.sendRedirect("/error.jsp");
            } catch (IOException e) {
            }
        }
        return null;
    }
}
